package com.zhiming.item.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zhiming.common.exception.pojo.ExceptionEnum;
import com.zhiming.common.exception.pojo.ZmException;
import com.zhiming.item.mapper.AboutMapper;
import com.zhiming.item.pojo.About;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 关于我们 Service
 */

@Service
public class AboutService {
    @Autowired(required = false)
    private AboutMapper aboutMapper;

    public List<About> getAboutInfo() {
        QueryWrapper<About> query = Wrappers.query();
        query.last("limit 1");
        About about = aboutMapper.selectOne(query);


        if(about ==null){
            throw new ZmException(ExceptionEnum.ABOUT_NOT_FOUND);
        }

        ArrayList<About> abouts = new ArrayList<>();
        abouts.add(about);
        System.out.println("关于我们数据=" + abouts);
        return abouts;
    }
}
